package com.webflux.repository;

import com.webflux.domain.User;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;

/**
 * Created by wangzhanjin on 2018/5/31.
 */
@Repository
public interface UserRepository extends ReactiveMongoRepository<User,String> {

    /**
     * 根据年龄查找用户
     * jpa的强大之处，只要写好就会生成
     * @param start
     * @param end
     * @return
     */
    Flux<User> findByAgeBetween(int start, int end);

    @Query("{'age':{'$gte':20,'$lte':29}}")
    Flux<User> oldUser();
}
